from django.conf.urls import url
from . import views

from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

urlpatterns = [
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.CheckUsernameView.as_view()),
    url(r'^phones/(?P<mobile>1[3456789]\d{9})/count/$', views.CheckMobileView.as_view()),
    url(r'^$', views.RegisterUserView.as_view()),
    # url(r'^auths/$', obtain_jwt_token),  # 登陆路由
    url(r'^auths/$', views.UserObtainJSONWebToken.as_view()),  # 重写登陆类视图路由
    url(r'^infos/$', views.UserInfoView.as_view()),
    url(r'^emails/$', views.EmailSendview.as_view()),  # 根据js前端代码编写邮箱子路由
    url(r'^emails/verification/$', views.EmailActiveview.as_view()),  # 激活路由
    # url(r'^addresses/$', views.Addressview.as_view({"get": "list", "post": "create"})),

    url(r'test/(?P<name>.+)/(?P<age>\d+)/$', views.TestView.as_view()),
    url(r'^browerhistories/$', views.UserBrowerHistoryView.as_view()),
    url(r'^accounts/(?P<username>\w+)/sms/token/$', views.RetrievepasswordView.as_view()),  # 获取图片验证码视图
    url(r'^sms_codes/$', views.SmscodeView.as_view()),  # 发送短信验证码视图
    url(r'^accounts/(?P<username>\w+)/password/token/$', views.GetsmscodeView.as_view()),  # 效验短信验证码，获取重置密码token　视图
    url(r'^(?P<user_id>\d+)/password/$', views.ResetPasswordView.as_view()),  # 重置密码
    url(r'^orders/$', views.ShowListordersView.as_view())  # 用户订单显示
]


# 创建DefaulRoute对象
router = DefaultRouter()

# 注册视图集
router.register(r'addresses', views.Addressview, base_name="address")

# 添加到urlpatterns
urlpatterns += router.urls
